const path = require('path')
function addStyleResource (rule) {
    rule.use('style-resource')
    .loader('style-resources-loader')
    .options({
        patterns: [
            path.resolve(__dirname, './src/assets/css/variable.scss'),
            path.resolve(__dirname, './src/assets/css/mixin.scss')
    ],
    })
   }

module.exports = {
    configureWebpack: {
        // 设置别名,直接在src中使用别名得在前面加~
        resolve: {
            alias: {
                'assets': '@/assets',
                'components': '@/components',
                'network': '@/network',
                'utils': '@/utils',
                'views': '@/views'
            }
        }
    },
    chainWebpack: config => {
        const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
        types.forEach(type => addStyleResource(config.module.rule('scss').oneOf(type)))
    }
}